<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style/global.css" />
<link rel="stylesheet" type="text/css" href="style/admin.css" />
<title>用户管理</title>
</head>
<style>
.pointer{
	cursor:pointer;
}
</style>
<body>
<div id="wrap">
<div id="public_head"></div>
<div class="m_revise" id="revise">
<form action="" method='post'>
<table class="tableForm user_table" width="0" border="0">
	<tr>
		<th height="45">用户组名称</th>
		<td>
			<input class="qf_text" name="name" value="<?php echo $roleinfo['ROLE_NAME']?>" type="text" />
		</td>
	</tr>
<?php if(CSM_UNIT_ID<0){?>
	<tr>
		<th height="45">所属医院</th>
		<td>
			<select name='unid' class='select'>
	<?php 
		if(is_array($allunit) && count($allunit)>0){
			foreach ($allunit as $k=>$v){
	?>
			<option value='<?php echo $k;?>'><?php echo $v;?></option>
	<?php 
			}
		}else{
	?>
			<option value='0'>暂无医院数据</option>
	<?php }?>
			</select>
		</td>
	</tr>
<?php }?>
	<tr>
		<th height="45">用户说明</th>
		<td><textarea class="textarea" name="description" cols="100%" rows="5"><?php echo $roleinfo['DESCRIPTION']?></textarea></td>
	</tr>
	<tr>
		<th height="45">权限分配</th>
		<td>
	<?php 
		if(is_array($allmenu) && count($allmenu)>0){
			foreach ($allmenu as $k=>$v){
	?>
			<dl>
				<dt><?php echo $v['title']?></dt>
				<?php 
					foreach ($v['menus'] as $key=>$val){
						if(!in_array($key, $havemenu) && CSM_UNIT_ID>0) continue;
				?>
				<dd>
					<input name="menus[]" class="mainmenu" flag="<?php echo $key?>" type="checkbox" <?php if(in_array($key, explode(',',$roleinfo['MENUS']))){echo ' checked ';}?> value="<?php echo $key;?>" />&nbsp;<?php echo $val['title']?>
					&nbsp;【<span class="checkall pointer red" flag="<?php echo $key;?>">全选</span>】
						<?php 
						if(isset($val['forms']) && is_array($val['forms']) && count($val['forms'])>0){
							echo "<br>|---【";
							foreach ($val['forms'] as $k=>$v){
								if(!in_array($k, $haveaction) && CSM_UNIT_ID>0) continue;
						?>
							<span><input class="action <?php echo $key?>_action" flag='<?php echo $key;?>' name="actions[]"<?php if(in_array($k, explode(',',$roleinfo['ACTIONS']))){echo ' checked ';}?> type="checkbox" value="<?php echo $k?>" />&nbsp;<?php echo $v['title']?></span> 
						<?php
							 }
							 echo "】";
						}
						?>
				</dd>
				<?php }?>
			</dl>
		<?php 
			}
		}
		?>
		</td>
	</tr>
	<tr>
		<th height="45"></th>
		<td>
			<input class="btn_save" name="add_role" type="submit" value=""/>
			<input class='btn_gray' type='button' value='返 回' onclick="history.back()"/>
		</td>
	</tr>
</table>
</form>
</div>
</div>
</body>
</html>

<script src="/js/xheditor/jquery/jquery-1.4.4.min.js"
	type="text/javascript"></script>
<script src="/js/boot.js" type="text/javascript"></script>
<script src="/js/tip.js" type="text/javascript"></script>
<script src="/js/add_public_head.js" type="text/javascript"></script>
<script type="text/javascript">
$('.action').click(function(){
	$(this).parents('dd').children('input').attr('checked',true)
	var flag = $(this).attr('flag');
	var t = '.'+flag+'_action:checked';
	var a = '.'+flag+'_action'
	if($(t).length <1){
		$(this).parents('dd').children('input').attr('checked',false)
		$(this).parents('dd').children('.checkall').html('全选')
	}
	if($(a).length == $(t).length){
		$(this).parents('dd').children('.checkall').html('取消')
	}else{
		$(this).parents('dd').children('.checkall').html('全选')
	}
})
$('.checkall').click(function(){
	var flag = $(this).attr('flag')
	var t = '.'+flag+'_action'
	if($(this).html() == '全选'){
		$(this).html('取消')
		$(t).attr('checked',true)
		$(this).parents('dd').children('input').attr('checked',true)
	}else{
		$(this).html('全选')
		$(t).attr('checked',false)
		$(this).parents('dd').children('input').attr('checked',false)
	}
	
})
$('.mainmenu').click(function(){
	var flag = $(this).attr('flag')
	var t = '.'+flag+'_action'
	if(!$(this).attr('checked')){
		$(t).attr('checked',false)
		$(this).parents('dd').children('.checkall').html('全选')
	}
})
$('dd').each(function(){
	var flag = $(this).children('.mainmenu').attr('flag')
	var t = '.'+flag+'_action:checked';
	var a = '.'+flag+'_action'
	if($(a).length == $(t).length){
		$(this).children('.checkall').html('取消')
	}else{
		$(this).children('.checkall').html('全选')
	}
})
</script>